Imports Clo = Enhancements.Core.Logging
Imports Cmp = System.Runtime.CompilerServices
Imports Epe = Enhancements.Basic.Primitives
Imports Ere = Enhancements.Basic.RegularExpressions
Imports Gen = System.Collections.Generic
Imports Iou = System.IO
Imports Ref = System.Reflection
Imports Reg = System.Text.RegularExpressions
Imports Sys = System
Imports Tex = System.Text
Imports Xsd = System.Xml.Schema
Imports W3c = System.Xml

Namespace Enhancements.Basic.Primitives
    ''' <summary>Contains features that add up to System.Int16 arrays.</summary>
    <Serializable(), DebuggerStepThrough()> _
    Public Module Int16Array

        ''' <summary>Represents an empty array.</summary>
        Public ReadOnly Empty() As System.Int16 = CType(Sys.Array.CreateInstance(GetType(System.Int16), 0), System.Int16())

        ''' <summary>Determines the hexadecimal representation of the values in an array.</summary>
        ''' <param name="_values">Values to represent.</param>
        ''' <param name="_separator">Separator used to separate the result's representations.</param>
        ''' <exception cref="IsNullException">_values is null, or _separator is null.</exception>
        ''' <exception cref="IsEmptyException">_separator is empty.</exception>
        ''' <exception cref="IsInRangeNotException">One or more values in _values are lower than 0 or higher than System.Int16.MaxValue.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function ToHexadecimalString(ByVal _values() As System.Int16, ByVal _separator As System.String) As String
            _values.IsNullNot("_values", True)
            _separator.IsEmptyNot("_separator", True)

            Dim _returnValueStringBuilder As Tex.StringBuilder = New Tex.StringBuilder(String.Empty)
            For _counter As Sys.Int32 = 0 To _values.Length - 2
                _returnValueStringBuilder.Append(Epe.Int16.ToHexadecimalString(_values(_counter)))
                _returnValueStringBuilder.Append(_separator)
            Next _counter
            If _values.Length >= 1 Then
                _returnValueStringBuilder.Append(Epe.Int16.ToHexadecimalString(_values(_values.Length - 1)))
            End If

            Return _returnValueStringBuilder.ToString()
        End Function

        ''' <summary>Determines the hexadecimal representation of the values in an array.</summary>
        ''' <param name="_values">Values to represent.</param>
        ''' <param name="_separator">Separator used to separate the result's representations.</param>
        ''' <exception cref="IsNullException">_values is null.</exception>
        ''' <exception cref="IsInRangeNotException">One or more values in _values are lower than 0 or higher than System.Int16.MaxValue.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function ToHexadecimalString(ByVal _values() As System.Int16, ByVal _separator As System.Char) As String
            Dim _returnValue As System.String = _values.ToHexadecimalString(CType(_separator, System.String))

            Return _returnValue
        End Function

        ''' <summary>Determines the values from their hexadecimal representations.</summary>
        ''' <param name="_values">Values to inspect.</param>
        ''' <param name="_separator">Separator used to separate the values hexadecimal representations.</param>
        ''' <exception cref="IsNullException">_value is null, or _separator is null.</exception>
        ''' <exception cref="IsEmptyException">_separator is empty.</exception>
        ''' <exception cref="IsInRegularExpressionNotException">One or more of the hexadecimal representations in _values are not well-formed.</exception>
        ''' <exception cref="IsInRangeNotException">One or more of the resulting values are lower than 0 or higher than System.Int16.MaxValue.</exception>
        ''' <returns> </returns>
        Public Function FromHexadecimalString(ByVal _values As System.String, ByVal _separator As System.String) As System.Int16()
            _values.IsNullNot("_values", True)
            _separator.IsEmptyNot("_separator", True)
            For Each _value As System.String In _values.Split(_separator)
                _value.IsInRegularExpression("_value", Ere.Repository.HexadecimalNumber, True)
            Next _value

            Dim _valuesSplitted() As System.String = _values.Split(_separator)
            Dim _returnValueList As Gen.List(Of System.Int16) = New Gen.List(Of System.Int16)
            For Each _value As System.String In _valuesSplitted
                _returnValueList.Add(Epe.Int16.FromHexadecimalString(_value))
            Next _value

            Return _returnValueList.ToArray()
        End Function

        ''' <summary>Determines the values from their hexadecimal representations.</summary>
        ''' <param name="_values">Values to inspect.</param>
        ''' <param name="_separator">Separator used to separate the values hexadecimal representations.</param>
        ''' <exception cref="IsNullException">_value is null.</exception>
        ''' <exception cref="IsInRegularExpressionNotException">One or more of the hexadecimal representations in _values are not well-formed.</exception>
        ''' <exception cref="IsInRangeNotException">One or more of the resulting values are lower than 0 or higher than System.Int16.MaxValue.</exception>
        ''' <returns> </returns>
        Public Function FromHexadecimalString(ByVal _values As System.String, ByVal _separator As System.Char) As System.Int16()
            Dim _returnValue() As System.Int16 = FromHexadecimalString(_values, CType(_separator, System.String))

            Return _returnValue
        End Function

        ''' <summary>Returns a part of an array.</summary>
        ''' <param name="_value">Base array.</param>
        ''' <param name="_beginIndex">Index of the extraction beginning.</param>
        ''' <param name="_endIndex">Index of the extraction ending.</param>
        ''' <exception cref="IsNullException">_value is null.</exception>
        ''' <exception cref="IsArrayEmptyException">_value is empty.</exception>
        ''' <exception cref="IsInRangeNotException">_beginIndex is lower than 0 or higher than _value.Length-1, or _endIndex is lower than _beginIndex or higher than _value.Length-1.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function SubArray(ByVal _value() As System.Int16, ByVal _beginIndex As Sys.Int32, ByVal _endIndex As Sys.Int32) As System.Int16()
            _value.IsArrayEmptyNot("_value", True)
            _beginIndex.IsInRange("_beginIndex", 0, _value.Length - 1, True)
            _endIndex.IsInRange("_endIndex", _beginIndex, _value.Length - 1, True)

            Dim _returnValue(_endIndex - _beginIndex) As System.Int16
            Sys.Array.Copy(_value, _beginIndex, _returnValue, 0, _endIndex - _beginIndex + 1)

            Return _returnValue
        End Function

        ''' <summary>Inserts an array in another array, in a given position.</summary>
        ''' <param name="_value">Base array.</param>
        ''' <param name="_index">Insertion position.</param>
        ''' <param name="_valueToInsert">Array to insert.</param>
        ''' <exception cref="IsNullException">_value is null, or _valueToInsert is null.</exception>
        ''' <exception cref="IsInRangeNotException">_index is lower than 0 or higher than _value.Length.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function Insert(ByVal _value() As System.Int16, ByVal _index As Sys.Int32, ByVal _valueToInsert() As System.Int16) As System.Int16()
            _value.IsNullNot("_value", True)
            _valueToInsert.IsNullNot("_valueToInsert", True)
            _index.IsInRange("_index", 0, _value.Length, True)

            Dim _returnValue() As System.Int16 = Nothing
            If _value.Length + _valueToInsert.Length = 0 Then
                _returnValue = Empty
            Else
                If _valueToInsert.Length = 0 Then
                    _returnValue = CType(_value.Clone(), System.Int16())
                Else
                    If _value.Length = 0 Then
                        _returnValue = CType(_valueToInsert.Clone, System.Int16())
                    Else
                        ReDim _returnValue(_value.Length + _valueToInsert.Length - 1)
                        Sys.Array.Copy(_value, 0, _returnValue, 0, _index)
                        Sys.Array.Copy(_valueToInsert, 0, _returnValue, _index, _valueToInsert.Length)
                        Sys.Array.Copy(_value, _index, _returnValue, _index + _valueToInsert.Length, _value.Length - _index)
                    End If
                End If
            End If

            Return _returnValue
        End Function

        ''' <summary>Inserts a value in an array, in a given position.</summary>
        ''' <param name="_value">Base array.</param>
        ''' <param name="_index">Insertion position.</param>
        ''' <param name="_valueToInsert">Value to insert.</param>
        ''' <exception cref="IsNullException">_value is null.</exception>
        ''' <exception cref="IsInRangeNotException">_index is lower than 0 or higher than _value.Length.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function Insert(ByVal _value() As System.Int16, ByVal _index As Sys.Int32, ByVal _valueToInsert As System.Int16) As System.Int16()
            _value.IsNullNot("_value", True)
            _index.IsInRange("_index", 0, _value.Length, True)

            Dim _returnValue() As System.Int16 = _value.Insert(_index, New System.Int16() {_valueToInsert})

            Return _returnValue
        End Function

        ''' <summary>Inserts an array in a value, in a given position.</summary>
        ''' <param name="_value">Base value.</param>
        ''' <param name="_index">Insertion position.</param>
        ''' <param name="_valueToInsert">Array to insert.</param>
        ''' <exception cref="IsNullException">_valueToInsert is null.</exception>
        ''' <exception cref="IsInRangeNotException">_index is lower than 0 or higher 1.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function Insert(ByVal _value As System.Int16, ByVal _index As Sys.Int32, ByVal _valueToInsert() As System.Int16) As System.Int16()
            _valueToInsert.IsNullNot("_valueToInsert", True)
            _index.IsInRange("_index", 0, 1, True)

            Dim _returnValue() As System.Int16 = (New System.Int16() {_value}).Insert(_index, _valueToInsert)

            Return _returnValue
        End Function

        ''' <summary>Inserts a value in another value, in a given position.</summary>
        ''' <param name="_value">Base value.</param>
        ''' <param name="_index">Insertion position.</param>
        ''' <param name="_valueToInsert">Value to insert.</param>
        ''' <exception cref="IsInRangeNotException">_index is lower than 0 or higher 1.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function Insert(ByVal _value As System.Int16, ByVal _index As Sys.Int32, ByVal _valueToInsert As System.Int16) As System.Int16()
            _index.IsInRange("_index", 0, 1, True)

            Dim _returnValue() As System.Int16 = (New System.Int16() {_value}).Insert(_index, New System.Int16() {_valueToInsert})

            Return _returnValue
        End Function

        ''' <summary>Returns an array that is the result of the removal of a part of another array.</summary>
        ''' <param name="_value">Base array.</param>
        ''' <param name="_beginIndex">Index of the removal beginning.</param>
        ''' <param name="_endIndex">Index of the removal ending.</param>
        ''' <exception cref="IsNullException">_value is null.</exception>
        ''' <exception cref="IsArrayEmptyException">_value is empty.</exception>
        ''' <exception cref="IsInRangeNotException">_beginIndex is lower than 0 or higher than _value.Length-1, or _endIndex is lower than _beginIndex or higher than _value.Length-1.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function Remove(ByVal _value() As System.Int16, ByVal _beginIndex As Sys.Int32, ByVal _endIndex As Sys.Int32) As System.Int16()
            _value.IsArrayEmptyNot("_value", True)
            _beginIndex.IsInRange("_beginIndex", 0, _value.Length - 1, True)
            _endIndex.IsInRange("_endIndex", _beginIndex, _value.Length - 1, True)

            Dim _returnValue() As System.Int16 = Nothing
            If _endIndex - _beginIndex + 1 = _value.Length Then
                _returnValue = Empty
            Else
                If _beginIndex >= 1 Then
                    _returnValue = _value.SubArray(0, _beginIndex - 1)
                Else
                    _returnValue = Empty
                End If
                If _endIndex + 1 < _value.Length Then
                    _returnValue = _returnValue.Insert(_returnValue.Length, _value.SubArray(_endIndex + 1, _value.Length - 1))
                End If
            End If

            Return _returnValue
        End Function

        ''' <summary>Appends an array to another array.</summary>
        ''' <param name="_value">Base array.</param>
        ''' <param name="_valueToInsert">Array to append.</param>
        ''' <exception cref="IsNullException">_value is null, or _valueToInsert is null.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function Append(ByVal _value() As System.Int16, ByVal _valueToInsert() As System.Int16) As System.Int16()
            _value.IsNullNot("_value", True)
            _valueToInsert.IsNullNot("_valueToInsert", True)

            Dim _returnValue() As System.Int16 = _value.Insert(_value.Length, _valueToInsert)

            Return _returnValue
        End Function

        ''' <summary>Appends a value to another array.</summary>
        ''' <param name="_value">Base array.</param>
        ''' <param name="_valueToInsert">Value to append.</param>
        ''' <exception cref="IsNullException">_value is null.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function Append(ByVal _value() As System.Int16, ByVal _valueToInsert As System.Int16) As System.Int16()
            _value.IsNullNot("_value", True)

            Dim _returnValue() As System.Int16 = _value.Append(New System.Int16() {_valueToInsert})

            Return _returnValue
        End Function

        ''' <summary>Appends an array to a value.</summary>
        ''' <param name="_value">Base value.</param>
        ''' <param name="_valueToInsert">Array to append.</param>
        ''' <exception cref="IsNullException">_valueToInsert is null.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function Append(ByVal _value As System.Int16, ByVal _valueToInsert() As System.Int16) As System.Int16()
            _valueToInsert.IsNullNot("_valueToInsert", True)

            Dim _returnValue() As System.Int16 = (New System.Int16() {_value}).Append(_valueToInsert)

            Return _returnValue
        End Function

        ''' <summary>Appends a value to another value.</summary>
        ''' <param name="_value">Base value.</param>
        ''' <param name="_valueToInsert">Value to append.</param>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function Append(ByVal _value As System.Int16, ByVal _valueToInsert As System.Int16) As System.Int16()
            Dim _returnValue() As System.Int16 = (New System.Int16() {_value}).Append(New System.Int16() {_valueToInsert})

            Return _returnValue
        End Function

        ''' <summary>Determines the occurrences of an array in another array.</summary>
        ''' <param name="_value">Base array.</param>
        ''' <param name="_valueToSearch">Array to search in the base array.</param>
        ''' <exception cref="IsNullException">_value is null, or _valueToSearch is null.</exception>
        ''' <exception cref="IsArrayEmptyException">_valueToSearch is empty.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function FindOccurrences(ByVal _value() As System.Int16, ByVal _valueToSearch() As System.Int16) As Occurrence()
            _value.IsNullNot("_value", True)
            _valueToSearch.IsArrayEmptyNot("_valueToSearch", True)

            Dim _returnValueList As Gen.List(Of Occurrence) = New Gen.List(Of Occurrence)
            If _value.Length >= 1 Then
                For _counter1 As Sys.Int32 = 0 To _value.Length - _valueToSearch.Length
                    Dim _occurrenceFound As System.Boolean = True
                    For _counter2 As Sys.Int32 = 0 To _valueToSearch.Length - 1
                        If _value(_counter1 + _counter2) <> _valueToSearch(_counter2) Then
                            _occurrenceFound = False
                            Exit For
                        End If
                    Next _counter2
                    If _occurrenceFound Then
                        _returnValueList.Add(New Occurrence(_counter1, _counter1 + _valueToSearch.Length - 1))
                        _counter1 += _valueToSearch.Length - 1
                    End If
                Next _counter1
            End If

            Return _returnValueList.ToArray()
        End Function

        ''' <summary>Determines the occurrences of a value in an array.</summary>
        ''' <param name="_value">Base array.</param>
        ''' <param name="_valueToSearch">Value to search in the base array.</param>
        ''' <exception cref="IsNullException">_value is null.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function FindOccurrences(ByVal _value() As System.Int16, ByVal _valueToSearch As System.Int16) As Occurrence()
            _value.IsNullNot("_value", True)

            Dim _returnValue() As Occurrence = _value.FindOccurrences(New System.Int16() {_valueToSearch})

            Return _returnValue
        End Function

        ''' <summary>Returns an array that is the result of the removal of the occurrences of an array in another array.</summary>
        ''' <param name="_value">Base array.</param>
        ''' <param name="_valueToRemove">Array to search and remove from the base array.</param>
        ''' <exception cref="IsNullException">_value is null, or _valueToRemove is null.</exception>
        ''' <exception cref="IsArrayEmptyException">_valueToRemove is empty.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function RemoveOccurrences(ByVal _value() As System.Int16, ByVal _valueToRemove() As System.Int16) As System.Int16()
            _value.IsNullNot("_value", True)
            _valueToRemove.IsArrayEmptyNot("_valueToRemove", True)

            Dim _returnValue() As System.Int16 = Nothing
            Dim _occurrences() As Occurrence = _value.FindOccurrences(_valueToRemove)
            If _occurrences.Length = 0 Then
                _returnValue = CType(_value.Clone(), System.Int16())
            Else
                If _value.Length = _occurrences.Length * _valueToRemove.Length Then
                    _returnValue = Empty
                Else
                    ReDim _returnValue(_value.Length - _occurrences.Length * _valueToRemove.Length - 1)
                    Dim _insertionIndex As Sys.Int32 = 0
                    If _occurrences(0).BeginIndex >= 1 Then
                        Sys.Array.Copy(_value, 0, _returnValue, _insertionIndex, _occurrences(0).BeginIndex)
                        _insertionIndex += _occurrences(0).BeginIndex
                    End If
                    For _counter As Sys.Int32 = 1 To _occurrences.Length - 1
                        Sys.Array.Copy(_value, _occurrences(_counter - 1).EndIndex + 1, _returnValue, _insertionIndex, _occurrences(_counter).BeginIndex - _occurrences(_counter - 1).EndIndex - 1)
                        _insertionIndex += _occurrences(_counter).BeginIndex - _occurrences(_counter - 1).EndIndex - 1
                    Next _counter
                    If _occurrences(_occurrences.Length - 1).EndIndex < _value.Length - 1 Then
                        Sys.Array.Copy(_value, _occurrences(_occurrences.Length - 1).EndIndex + 1, _returnValue, _insertionIndex, _value.Length - _occurrences(_occurrences.Length - 1).EndIndex - 1)
                    End If
                End If
            End If

            Return _returnValue
        End Function

        ''' <summary>Returns an array that is the result of the removal of the occurrences of a value in an array.</summary>
        ''' <param name="_value">Base array.</param>
        ''' <param name="_valueToRemove">Value to search and remove from the base array.</param>
        ''' <exception cref="IsNullException">_value is null.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function RemoveOccurrences(ByVal _value() As System.Int16, ByVal _valueToRemove As System.Int16) As System.Int16()
            _value.IsNullNot("_value", True)

            Dim _returnValue() As System.Int16 = _value.RemoveOccurrences(New System.Int16() {_valueToRemove})

            Return _returnValue
        End Function

        ''' <summary>Returns an array that is the result of the replacement of the occurrences of an array in another array, with a replacement one.</summary>
        ''' <param name="_value">Base array.</param>
        ''' <param name="_valueToSearch">Array to search and replace from the base array.</param>
        ''' <param name="_valueToReplace">Replacement array.</param>
        ''' <exception cref="IsNullException">_value is null, or _valueToSearch is null, or _valueToReplace is null.</exception>
        ''' <exception cref="IsArrayEmptyException">_valueToSearch is empty.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function ReplaceOccurrences(ByVal _value() As System.Int16, ByVal _valueToSearch() As System.Int16, ByVal _valueToReplace() As System.Int16) As System.Int16()
            _value.IsNullNot("_value", True)
            _valueToSearch.IsArrayEmptyNot("_valueToSearch", True)
            _valueToReplace.IsNullNot("_valueToReplace", True)

            Dim _returnValue() As System.Int16 = Nothing
            Dim _occurrences() As Occurrence = _value.FindOccurrences(_valueToSearch)
            If _occurrences.Length = 0 Then
                _returnValue = CType(_value.Clone(), System.Int16())
            Else
                ReDim _returnValue(_value.Length - _occurrences.Length * _valueToSearch.Length + _occurrences.Length * _valueToReplace.Length - 1)
                Dim _insertionIndex As Sys.Int32 = 0
                If _occurrences(0).BeginIndex >= 1 Then
                    Sys.Array.Copy(_value, 0, _returnValue, _insertionIndex, _occurrences(0).BeginIndex)
                    _insertionIndex += _occurrences(0).BeginIndex
                    Sys.Array.Copy(_valueToReplace, 0, _returnValue, _insertionIndex, _valueToReplace.Length)
                    _insertionIndex += _valueToReplace.Length
                Else
                    Sys.Array.Copy(_valueToReplace, 0, _returnValue, _insertionIndex, _valueToReplace.Length)
                    _insertionIndex += _valueToReplace.Length
                End If
                For _counter As Sys.Int32 = 1 To _occurrences.Length - 1
                    Sys.Array.Copy(_value, _occurrences(_counter - 1).EndIndex + 1, _returnValue, _insertionIndex, _occurrences(_counter).BeginIndex - _occurrences(_counter - 1).EndIndex - 1)
                    _insertionIndex += _occurrences(_counter).BeginIndex - _occurrences(_counter - 1).EndIndex - 1
                    Sys.Array.Copy(_valueToReplace, 0, _returnValue, _insertionIndex, _valueToReplace.Length)
                    _insertionIndex += _valueToReplace.Length
                Next _counter
                If _occurrences(_occurrences.Length - 1).EndIndex < _value.Length - 1 Then
                    Sys.Array.Copy(_value, _occurrences(_occurrences.Length - 1).EndIndex + 1, _returnValue, _insertionIndex, _value.Length - _occurrences(_occurrences.Length - 1).EndIndex - 1)
                End If
            End If

            Return _returnValue
        End Function

        ''' <summary>Returns an array that is the result of the replacement of the occurrences of an array in another array, with a replacement value.</summary>
        ''' <param name="_value">Base array.</param>
        ''' <param name="_valueToSearch">Array to search and replace from the base array.</param>
        ''' <param name="_valueToReplace">Replacement value.</param>
        ''' <exception cref="IsNullException">_value is null, or _valueToSearch is null.</exception>
        ''' <exception cref="IsArrayEmptyException">_valueToSearch is empty.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function ReplaceOccurrences(ByVal _value() As System.Int16, ByVal _valueToSearch() As System.Int16, ByVal _valueToReplace As System.Int16) As System.Int16()
            _value.IsNullNot("_value", True)
            _valueToSearch.IsArrayEmptyNot("_valueToSearch", True)

            Dim _returnValue() As System.Int16 = _value.ReplaceOccurrences(_valueToSearch, New System.Int16() {_valueToReplace})

            Return _returnValue
        End Function

        ''' <summary>Returns an array that is the result of the replacement of the occurrences of a value in an array, with a replacement one.</summary>
        ''' <param name="_value">Base array.</param>
        ''' <param name="_valueToSearch">Value to search and replace from the base array.</param>
        ''' <param name="_valueToReplace">Replacement array.</param>
        ''' <exception cref="IsNullException">_value is null, or _valueToReplace is null.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function ReplaceOccurrences(ByVal _value() As System.Int16, ByVal _valueToSearch As System.Int16, ByVal _valueToReplace() As System.Int16) As System.Int16()
            _value.IsNullNot("_value", True)
            _valueToReplace.IsNullNot("_valueToReplace", True)

            Dim _returnValue() As System.Int16 = _value.ReplaceOccurrences(New System.Int16() {_valueToSearch}, _valueToReplace)

            Return _returnValue
        End Function

        ''' <summary>Returns an array that is the result of the replacement of the occurrences of a value in another array, with a replacement value.</summary>
        ''' <param name="_value">Base array.</param>
        ''' <param name="_valueToSearch">Value to search and replace from the base array.</param>
        ''' <param name="_valueToReplace">Replacement value.</param>
        ''' <exception cref="IsNullException">_value is null.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function ReplaceOccurrences(ByVal _value() As System.Int16, ByVal _valueToSearch As System.Int16, ByVal _valueToReplace As System.Int16) As System.Int16()
            _value.IsNullNot("_value", True)

            Dim _returnValue() As System.Int16 = _value.ReplaceOccurrences(New System.Int16() {_valueToSearch}, New System.Int16() {_valueToReplace})

            Return _returnValue
        End Function

        ''' <summary>Returns an array that is the result of the inversion of another array.</summary>
        ''' <param name="_value">Base array.</param>
        ''' <exception cref="IsNullException">_value is null.</exception>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function Invert(ByVal _value() As System.Int16) As System.Int16()
            _value.IsNullNot("_value", True)

            Dim _returnValue() As System.Int16 = CType(Sys.Array.CreateInstance(GetType(System.Int16), _value.Length), System.Int16())
            For _counter As Sys.Int32 = 0 To _value.Length - 1
                _returnValue(_counter) = _value(_value.Length - _counter - 1)
            Next _counter

            Return _returnValue
        End Function

        ''' <summary>Evaluates if two arrays are equal in existence, and if both are not null, in size and content.</summary>
        ''' <param name="_valueFirst">First array.</param>
        ''' <param name="_valueSecond">Second array.</param>
        ''' <returns> </returns>
        <Cmp.Extension()> _
        Public Function AreEqual(ByVal _valueFirst() As System.Int16, ByVal _valueSecond() As System.Int16) As System.Boolean
            Dim _returnValue As System.Boolean = False
            If _valueFirst.IsNull("_valueFirst", False) AndAlso _valueSecond.IsNull("_valueSecond", False) Then
                _returnValue = True
            Else
                If _valueFirst.IsNullNot("_valueFirst", False) AndAlso _valueSecond.IsNullNot("_valueSecond", False) Then
                    If _valueFirst.Length.IsInRange("_valueFirst.Length", _valueSecond.Length, _valueSecond.Length, False) Then
                        If _valueFirst.Length.IsInRange("_valueFirst.Length", 0, 0, False) Then
                            _returnValue = True
                        Else
                            _returnValue = True
                            For _counter As Sys.Int32 = 0 To _valueFirst.Length - 1
                                If _valueFirst(_counter) <> _valueSecond(_counter) Then
                                    _returnValue = False
                                    Exit For
                                End If
                            Next _counter
                        End If
                    End If
                End If
            End If

            Return _returnValue
        End Function

    End Module
End Namespace
